<template>
    <div class="list-container">
        <ul v-if="dyjlist.length">
            <li v-for="(item,index) in dyjlist" :key="index">
                <div class="coupon-detail lcj-detail" :class="'lcj-state-' + couponstate">
                    <div class="clearfix">
                        <div class="left">
                            <p class="money">
                                <i>￥</i>
                                <span class="integermoney">{{item.formatCouponValue.integermoney}}</span>
                                <span class="decimalmoney">{{item.formatCouponValue.decimalmoney}}</span>
                            </p>
                        </div>
                        <div class="right">
                            <p class="time">有效期至{{item.expiredTime }}</p>
                            <p class="limitmoney">{{item.comments}}</p>
                        </div>
                    </div>
                    <p class="cut-off-rule"><i class="left-circular"></i><i class="right-circular"></i></p>
                    <p class="bottomdetail clearfix">
                        <span class="releasetime">{{item.givenTime + '发放'}}</span>
                    </p>
                    <p class="hasused-detail" v-if="couponstate === '2'">
                        <span class="usedtime">{{item.useComment }}</span>
                        <span class="purpose">{{'使用时间' + item.useTime}}</span>
                    </p>
                </div>
            </li>
        </ul>
        <div class="isloding" v-else-if="isLoading">
            <mt-spinner :type="3" :size="30"></mt-spinner>
        </div>
        <div class="hasnothing" v-else>
            <img src="~/assets/img/nothing.png" />
            <p class="hasnothing-tips">暂无抵用金</p>
        </div>
    </div>
</template>
<script>
  import conv from '~/helper/conv'
  export default {
    name: 'dyj-coupon-list',
    props: {
      list: {
        type: Array,
        default: () => []
      },
      isLoading: {
        type: Boolean
      },
      couponstate: {
        type: String
      }
    },
    computed: {
      dyjlist () {
        var items = this.list
        items.forEach(item => {
          item.formatCouponValue = {
            integermoney: parseInt(item.lcjValue / 100),
            decimalmoney: '.' + ((item.lcjValue % 100) < 10 ? '0' : '') + (item.lcjValue % 100)
          }
          item.expiredTime = (item.expiredTime) ? conv.toDateStr(item.expiredTime, 'yyyy-MM-dd') : ''
          item.givenTime = (item.givenTime) ? conv.toDateStr(item.givenTime, 'yyyy-MM-dd') : ''
          item.limittypes = item.productTypes ? item.productTypes : ''
          item.useTime = (item.useTime) ? conv.toDateStr(item.useTime, 'yyyy-MM-dd') : ''
        })
        return items
      }
    }
  }
</script>

<style scoped lang='sass' src='~/assets/sass/coupon.sass'></style>